24 August 2000
Source:
http://senderek.de/security/key-experiments.html
- How PGP Deals With Manipulated Keys -
An Experimental Approach by
Ralf Senderek
August 2000
________________________________________
Different versions of PGP show considerably different reactions when being confronted with public keys which have been subsequently manipulated. Especially a subsequent contamination of a public key with another person's key will not be noticed and rejected if you use newer versions of PGP, but will be used to produce encrypted messages which can be read in plaintext by everyone who has the secret key corresponding to the key which was smuggled into the original one. This manipulation will not be detected when using some newer versions of PGP and will not be noticed until users are going to have a detailed look at the bytes of the manipulated keys. This study helps to understand this threat, to find out experimentally how a specific version of PGP reacts, and to avoid being cheated with manipulated keys.
________________________________________
The Curse of Additional Decryption Keys
Since Diffie-Hellman/ElGamal-keys have been introduced with PGP-5.x in 1997 the valuation of PGP became more and more complex. Not only new cryptographic methods, different ciphers for encryption and a new digital signature standard (DSS) with a different public key cryptosystem had come up whose security and reliability had to be compared to the already well-known RSA-keys which brought some confusion about necessary key lengths but also NAIs engagement with the key recovery alliance (KRA) and the introduction of Additional Decryption Keys (ADKs) for data recovery by a third party - sometimes called Corporate Message Recovery (CMR) - made it extremely difficult for most users to decide which version of PGP they should use to ensure safe performance and to avoid unwanted side-effects.
Additional Decryption Keys had got into the center of criticism because they are linked to a user's public key in a way that every attempt to use the user's public key for encryption would result in an additional encryption of the plaintext using the ADK. Therefore no access to the user's secret key was needed to recover the plaintext by decrypting the message with the ADK, a key which was clearly meant not to be in control of the user. Criticism has focussed on the fact that the link between a user's key and a third-party-ADK creates a perfect means of surveillance of the user's encrypted communication and data, which would effectively result in third-party-access to plaintext as had been pursued previously by key escrow. Same effect but presented to the user in a nicer way.
If you do not find anything wrong with ADKs or even if you are happy with this new feature of data recovery the substantial analysis of the risks of third party encryption done by some eleven experts in cryptography might spark some doubts concerning ADKs.
But if you consider Additional Decryption Keys as a serious threat to privacy - as I do - you might have asked yourself or others some of the following questions without coming to satisfying conclusions:
It is easy to see why a satisfying answer to those questions is extremely difficult to achieve.
How can you be sure? You are confronted with different key-formats and you will probably not know all the implications or you will not have the knowledge in matters of cryptography and coding to judge for yourself.
Whose expertise would you trust? Is NAI's (or Zimmermann's) assessment on the matter trustworthy after all the confusion they had helped to create with the new versions?
There always is the hope a newer version of PGP will correct flaws and problems of older versions but how can you be sure the newer one does not create more problems by replacing well-approved components by fashionable ones? Trust in the latest version can be deceptive as long as you have no evidence. But what could possibly serve as a source of evidence for a sound valuation you are looking for so desperately?
The obvious answer would be: A competent and trustworthy expert with a good reputation both in the field of cryptography and as a privacy activist should scrutinize the source code of the latest version of PGP and should sign it after all doubts concerning trap-doors and malfunction have been destroyed by thorough analysis.
Although I think it to be possible to find such persons I doubt that they could do what you expect because their judgement would have to include the valuation of the cryptographic quality of a complex software system whose source code had been growing rapidly the current release reaching a couple of megabytes. No expert who wishes to be taken seriously would expose himself to the risk of having missed some detail or having misinterpreted some functionality relevant to the security of the whole complex system. So we cannot expect someone to play this part which clearly shows the curse of ADKs again.
On the other hand we cannot just ignore the dangling threat of surveillance ADKs have imposed on PGP simply by putting blind trust into every new version of PGP.
________________________________________
The Experimental Approach
What else can we do?
As someone with some experience in natural sciences I would like to suggest to take the scientific approach to the problem and simply put different versions of PGP to the test how they deal with manipulated public keys to show a way out of the uncertainty of the present situation.
Not what somebody says they will do but rather what they really do should be the base for a reliable decision on PGP. I know all results of experimental research only show some detail and great care should be taken when generalizing these facts. I know as well - as David Hume would put it - that every generalization is false. But to find out how different versions of PGP really react to experiments designed according to a scientific analysis to me seems to be a way out of the disaster.
At least the experimental approach provides the user with a method,
This I hope is more than most of the users of PGP are having at the moment.
________________________________________
Key-Experiments: A Summary of the Results
Additional Decryption Keys have been justified especially by Jon Callas, Chief Scientist of Pretty Good Privacy Inc. as a solution for data recovery which will help to prevent government regulation on cryptography. Mr. Callas emphasized his point that an ethically built data recovery software must be surveillance-surely and must be an »opt-in«-system. Linking ADKs to a user's private key should not be possible without the user's consent and in full control of the user, an option you can use if you like and which will require your consent to be active. Furthermore ADKs were designed for use within a closed group of individuals, i.e. in a company and will not affect the use of user's keys who do not wish to benefit from ADKs.
But the results of my experiments with manipulated PGP-keys clearly show the alarming truth, that this appeasement is completely untrue, because many users who don't have consented to the use of ADKs simply have no reliable means to protect their keys against subsequent manipulations which contaminate their keys with working ADKs. To have your key ADKed without your knowledge requires no »opting-in«. And this for sure should never have happened.
To suit the impatient reader I would like to summarize some of the essential results of my experiments and the conclusions which follow inevitably from these experiments before I go into greater detail.
The following chapters will give detailed information on how signatures and keys are built and will describe the experiments I have performed in some detail. If you like to continue directly with the comprehensive discussion of the consequences you can skip the following chapters.
________________________________________
Understanding Keys and Signatures
Because of the fact that you can only find little information about the structure of PGP-keys the document that describes the OpenPGP-standard published as RFC-2440 was of great help for me even if it contains not a single sentence which deals with ADKs. When PGP-5.x was introduced the way keys were stored and signatures were made changed dramatically. The new format internally became known as Version-4, while the classic old format, PGP-2.6x had already used, was called Version-3, strange but so it is.
As you might know with PGP-5.x (Version-4 format) the following new features came up:
Therefore a RSA-key will have a different fingerprint and a different Key-ID in both formats even if the essential key-material, the modulus and the encryption numbers are identical.
You can think of all information in a public key block as stored in a sequence of packets of data. Every packet consists of one byte which defines the type of the packet followed by an information on the length of the packet (2 bytes) followed by the rest of the data.
If you look at the packets which define the key-material the differences between Version-4 and Version-3 key-packets are not too impressive. Both start with the byte 153, which indicates a public-key-packet. Version-4-subkeys would start with 185. The next two bytes define the length of the whole packet in bytes and the third shows the version-number. The following four bytes give a number that indicates the key's time of creation measured in seconds since 1.1.1970. Version-3-keys then have two bytes which indicate the expiration time in days after creation and these two bytes are missing in the Version-4-format. The next byte gives the public key algorithm which can be RSA=1 for both and ElGamal=16 or DSS=17 for Version-4-keys. The rest of bytes hold "the essential key-material" which is two Multi-Precision-Integers for RSA and with Version-4-keys two, three, or four respectively. A Multi-Precision-Integer is a very long number with the length in bits stored in the first two bytes followed by all the bits that make up the entire number.
As you can see a classic Version-3-RSA-key can easily be transformed to Version-4-format by deleting the expiration time, changing the version byte to 4 and decrementing the lower length bytes by two. Voila.
A more dramatic change had been introduced in the field of signatures. The new signature-format is not only much more complex than the old signatures but at the same time it has become much more "open", unfortunately open for abuse as well. Let me summarize some of the more important changes in the V-4-signature-format:
But have a look at the following comparison:
As you can see Version-3 or classic signatures have no complicated design, after the usual byte 137 or 136 which identifies a signature and the packet length they contain a block of data comprising the version number and 5 bytes of data , the type of the signature, that means whether it signs a text or a key or a key with a user-ID, and the creation time. This block of 7 bytes will be hashed together with the data to be signed and will be protected by the signature. The rest of the signature-packet is the signer's key-ID, the public-key-algorithm and hash-algorithm, which always is RSA and MD5, and the first 16 bits of the 128-bit hashvalue which is encrypted with the signer's secret key and stored as a MPI at the end of the packet.
Version-4 keys have a similar structure starting with a 4 byte block including type and algorithms but without creation time. This block is hashed with the signature. Following this block there is a field of data with variable length containing any number of signature-subpackets which can hold a vast variety of additional information. Usually the creation time is included as a subpacket of type 02. All those subpackets are hashed as well and every information placed here is protected by the signature.
Another field of information which also can hold any number of signature-subpackets follows the first field. But unlike the first field all information in the second will not be hashed and therefore nothing stored here is protected by the signature. That clearly means, that data in this field, I call it the NON-HASHED FIELD of a signature, can be changed without any change of the validity of the signature. Changes in the first field will inevitably result in a corrupt signature, but changes in the second will not.
The rest of the V4-signature-packet simply holds 2 bytes of the hashvalue which now might be created using SHA1 instead of MD5 and one (RSA) or more MPIs (DSS) for the encrypted signature data.
Looking for the Additional Decryption Key
Where would an Additional Decryption Key be stored?
Before I started to analyse the bytes of a public key block I suspected it to be part of the "key" in one way or another. But as we now know, where should it hide? Even V4-key-packets can only be expanded at the end of the packet where MPIs are stored. V3-key packets have a fixed length with only one MPI at the end.
To answer this question I would like to refer to the fact that as early as 1997 Kai Raven had drawn the attention of the public to the existence of Corporate Message Recovery Keys (CMRK) in his excellent PGP manual for beginners published in German. He presented a file to download with two keys, one containing an ADK called "CMR User" and the corresponding public key "Little Brother".
I would like to invite you to have a closer look at the bytes of the first key which contains an ADK. Here it is , don't be startled, I will unveil all the mystery in a second :
0 1 2 3 4 5 6 7 8 9
0 : 153 1 66 4 52 77 70 30 17 3
10 : 0 208 110 105 167 56 168 248 25 85
20 : 51 185 141 4 40 211 238 226 54 148
30 : 172 29 236 121 194 253 56 249 84 2
40 : 247 82 40 41 43 251 221 124 45 186
50 : 73 152 122 36 203 219 54 8 235 33
60 : 131 80 5 88 239 186 186 252 25 169
70 : 229 144 250 251 164 23 184 179 122 112
80 : 61 248 223 108 220 33 180 250 145 17
90 : 46 189 114 9 143 253 135 167 97 74
100 : 120 142 235 35 98 104 207 0 160 255
110 : 164 105 123 98 12 109 92 210 78 33
120 : 223 148 171 233 166 145 243 66 229 3
130 : 0 175 68 6 231 162 65 44 19 93
140 : 141 202 124 191 56 233 48 113 190 93
150 : 243 97 3 55 182 245 181 60 224 43
160 : 236 74 42 127 190 192 58 128 89 191
170 : 199 34 165 244 22 251 132 61 48 155
180 : 239 220 44 124 155 42 185 44 201 228
190 : 212 128 134 30 194 159 62 37 232 49
200 : 196 163 251 241 88 98 52 141 201 215
210 : 71 244 4 0 166 200 98 113 195 24
220 : 41 87 60 56 154 252 100 3 0 151
230 : 80 120 105 31 80 47 69 47 120 36
240 : 203 172 144 176 78 225 92 57 71 199
250 : 94 126 151 21 95 69 241 166 238 192
260 : 129 62 88 186 101 111 243 124 59 225
270 : 245 134 19 243 27 103 87 82 237 77
280 : 221 7 8 115 143 7 164 33 127 111
290 : 15 141 241 228 53 165 99 32 66 64
300 : 12 246 214 222 54 33 78 230 138 124
310 : 19 128 18 236 232 203 179 228 214 144
320 : 245 101 8 77 10 180 28 67 77 82
330 : 32 85 115 101 114 32 60 115 110 111
340 : 111 112 101 100 64 108 111 99 97 108
350 : 104 111 115 116 62 136 99 4 16 17
360 : 2 0 35 5 2 52 77 70 30 23
370 : 10 128 17 38 165 102 122 151 212 112
380 : 24 27 24 43 21 214 49 71 118 182
390 : 112 225 208 4 11 3 1 2 0 10
400 : 9 16 52 164 96 86 238 66 48 227
410 : 216 255 0 160 138 116 238 85 15 190
420 : 92 25 233 49 164 13 75 190 67 131
430 : 57 166 224 30 0 160 186 50 232 251
440 : 6 243 116 201 62 127 23 12 197 224
450 : 110 132 183 160 145 213 136 70 4 16
460 : 17 2 0 6 5 2 52 77 72 93
470 : 0 10 9 16 214 49 71 118 182 112
480 : 225 208 245 210 0 158 45 156 245 91
490 : 207 216 81 91 217 144 172 14 142 155
500 : 226 34 8 157 125 17 0 158 53 57
510 : 128 28 213 252 169 63 20 30 99 108
520 : 148 86 167 199 221 233 166 4 185 0
530 : 205 4 52 77 70 42 16 3 0 240
540 : 8 91 147 80 78 79 222 192 30 139
550 : 40 213 68 86 9 23 144 6 51 170
560 : 227 253 23 34 90 211 75 105 40 216
570 : 132 68 41 31 98 250 38 254 153 177
580 : 130 100 0 246 49 164 11 22 188 191
590 : 239 56 126 36 94 141 119 173 241 238
600 : 54 132 10 100 211 170 95 66 181 213
610 : 46 166 32 123 163 198 96 140 38 65
620 : 103 43 220 233 98 219 24 130 92 219
630 : 208 189 184 172 133 0 2 2 3 0
640 : 154 54 140 196 55 36 25 23 165 20
650 : 73 20 116 146 226 245 197 193 33 232
660 : 120 163 84 246 17 204 186 102 217 220
670 : 253 148 95 170 44 113 27 171 59 8
680 : 2 102 41 58 158 178 166 250 110 118
690 : 17 219 150 135 222 206 193 66 44 113
700 : 62 151 40 75 62 147 37 73 165 167
710 : 101 232 5 240 146 254 159 228 143 250
720 : 179 41 220 204 90 148 145 138 32 32
730 : 91 36 102 25 87 243 136 70 4 24
740 : 17 2 0 6 5 2 52 77 70 42
750 : 0 10 9 16 52 164 96 86 238 66
760 : 48 227 114 226 0 160 161 180 188 226
770 : 178 60 139 95 117 117 194 74 217 8
780 : 231 254 240 142 156 67 0 160 159 251
790 : 117 86 3 156 180 204 37 162 137 181
800 : 176 132 9 0 145 235 55 202
Roughly speaking the key consists of six different packets, each beginning with an identifier-byte (in red) followed by two bytes which give the length (in blue) of the following data (in black).
I have found it a great help to use GnuPG as a packet-analysing-tool, because if you invoke GnuPG as
"gpg --list-packets key-A"
the result speaks for itself:
:public key packet:
version 4, algo 17, created 877479454, expires 0
pkey[0]: [768 bits]
pkey[1]: [160 bits]
pkey[2]: [768 bits]
pkey[3]: [768 bits]
:user ID packet: "CMR User "
:signature packet: algo 17, keyid 34A46056EE4230E3
version 4, created 877479454, md5len 0, sigclass 10
digest algo 2, begin of digest d8 ff
hashed subpkt 2 len 5 (sig created 1997-10-22)
hashed subpkt 10 len 23 (additional recipient request)
hashed subpkt 11 len 4 (pref-sym-algos: 3 1 2)
subpkt 16 len 9 (issuer key ID 34A46056EE4230E3)
data: [160 bits]
data: [160 bits]
:signature packet: algo 17, keyid D6314776B670E1D0
version 4, created 877480029, md5len 0, sigclass 10
digest algo 2, begin of digest f5 d2
hashed subpkt 2 len 5 (sig created 1997-10-22)
subpkt 16 len 9 (issuer key ID D6314776B670E1D0)
data: [158 bits]
data: [158 bits]
:public sub key packet:
version 4, algo 16, created 877479466, expires 0
pkey[0]: [768 bits]
pkey[1]: [2 bits]
pkey[2]: [768 bits]
:signature packet: algo 17, keyid 34A46056EE4230E3
version 4, created 877479466, md5len 0, sigclass 18
digest algo 2, begin of digest 72 e2
hashed subpkt 2 len 5 (sig created 1997-10-22)
subpkt 16 len 9 (issuer key ID 34A46056EE4230E3)
data: [160 bits]
data: [160 bits]
As you can see the ADK is sitting in the self-signature in a subpacket of type 10 called (additional recipient request (ARR)) in the first field of subpackets which are hashed and therefore are protected by the self-signature.
May I take you to the bare bone, bytes 355 to 455 of the self-signature packet, in detail:
350 : 136 99 4 16 17
360 : 2
--------------------------------------------------
0 35 | 5 2 52 77 70 30 | 23 HASHED subpackets
370 : 10 128 17 38 165 102 122 151 212 112
380 : 24 27 24 43 21 214 49 71 118 182
390 : 112 225 208 | 4 11 3 1 2
---------------------------------------------
---------
0 10 NON-HASHED subpackets
400 : 9 16 52 164 96 86 238 66 48 227
---------
410 : 216 255 2 leftmost bytes of hashvalue
0 160 138 116 238 85 15 190 MPI signature-r
420 : 92 25 233 49 164 13 75 190 67 131
430 : 57 166 224 30
0 160 186 50 232 251 MPI signature-s
440 : 6 243 116 201 62 127 23 12 197 224
450 : 110 132 183 160 145 213
You see a version number 4 (357) and a signature-type 16 (358) which means this signature signs a key and a user-ID followed by 17=DSS and 2=SHA1, the used algorithms. After that the first field of hashed subpackets begins carrying 3 subpackets of a total of 35 bytes.
The first one has length 5 (in green) and subpacket-type 2 (in brown), which is the signature creation time stored in the following 4 bytes as usual. By the way the time is (((((52*256)+77)*256)+70)*256)+30 = 877479454 seconds since January 1st 1970.
The second subpacket is 23 bytes long and of type 10, as you might remember the OpenPGP-draft states "placeholder for backward compatibility", following some 22 bytes of information. The first one 128 makes sure, that the ADK which is stored here will be "required", not only "welcome", to be used the second one 17 states that the ADK is a DSS-key and the following 20 bytes hold the fingerprint of the ADK to use:
DECIMAL : 38 165 102 122 151 212 112 24 27 24 43 21 214 49 71 118 182 112 225 208 HEXADECIMAL: 26 A5 66 7A 97 D4 70 18 1B 18 2B 15 D6 31 47 76 B6 70 E1 D0
This is the reference to Little Brother's signing key, as you may see from the reference in the chapter "The Keys for Experiments" below.
The last 4 byte subpacket of type 11 holds the preferred algorithms for symmetric encryption.
To complete our analysis, the next bytes are the NON-HASHED subpackets with only one 9 byte long packet of type 16 which holds the 8 bytes of the signer's key-ID, that is 34A46056EE4230E3. Note, that only the last 4 bytes appear as the key-ID 0xEE4230E3. The following last two packets hold a 160-bit MPI each, which makes up the encrypted hashvalue, called signature-r and signature-s. After having located the ADK in the self-signature we now can use it to encrypt a text for the user "CMR User" which we can analyse with GnuPG.
gpg: encrypted with 768-bit ELG-E key, ID FF2BBFFD, created 1997-10-22
"Little Brother "
gpg: no secret key for decryption available
gpg: encrypted with 768-bit ELG-E key, ID 183FBE34, created 1997-10-22
"CMR User "
gpg: no secret key for decryption available
gpg: decryption failed: secret key not available
:marker packet:
50 47 50
:pubkey enc packet: version 3, algo 16, keyid 5974B0A8183FBE34
data: [764 bits]
data: [766 bits]
:pubkey enc packet: version 3, algo 16, keyid 0C287D40FF2BBFFD
data: [768 bits]
data: [768 bits]
:encrypted data packet:
length: 40
Because of the fact, that we do not have any secret keys for both keys we are not able to decrypt the message, but as you see there is an additional packet which encrypts the session key used for encryption to the key-ID 0xFF2BBFFD which is the ElGamal-key bound as subkey to Little Brother's master-signing-key, whose fingerprint was stored in the ADK-subpacket originally. So "Little Brother", who has the secret key will be able to read the plaintext of the message, as well as "CMR User" who will use his key 0x183FBE34 to decrypt the message.
________________________________________
And after having performed intense tests on different versions of PGP with these keys the answers to the questions I mentioned did actually become clear to me but not in the way I was expecting.
________________________________________
To guard you through the experiments I will supply you with a detailed summary of all the keys I have created and their manipulated variations designed for the experiments. Each line provides two links one to a readable and of course printable description and one to the key itself. You can also use this file containing all the keys and their documentation.
pub 768D/EE4230E3 1997-10-22 CMR UserKey fingerprint = EC79 A170 8BAE 60A1 3CAC C517 34A4 6056 EE42 30E3 sig EE4230E3 1997-10-22 CMR User sig B670E1D0 1997-10-22 Little Brother sub 768g/183FBE34 1997-10-22 sig EE4230E3 1997-10-22 CMR User pub 768D/B670E1D0 1997-10-22 Little Brother Key fingerprint = 26A5 667A 97D4 7018 1B18 2B15 D631 4776 B670 E1D0 sig B670E1D0 1997-10-22 Little Brother sub 768g/FF2BBFFD 1997-10-22 sig B670E1D0 1997-10-22 Little Brother pub 1024D/149C79AB 2000-07-31 Billy Clean (Testkey DSS) Key fingerprint = 2E3C C603 91E1 3246 7DCF C722 9B80 46D9 149C 79AB sig 149C79AB 2000-07-31 Billy Clean (Testkey DSS) sub 1024g/11EE9145 2000-07-31 sig 149C79AB 2000-07-31 Billy Clean (Testkey DSS) pub 1024D/D41742F6 2000-06-23 control Key fingerprint = 77A4 052D 034F E3DE 2CE8 1054 5615 9937 D417 42F6 sig D41742F6 2000-06-23 control sub 2048g/2930391C 2000-06-23 sig D41742F6 2000-06-23 control pub 1024R/A7CE4BF5 2000-08-06 datarecovery RSA-ADK Key fingerprint = 3AA9 B31D 6D93 FD10 F835 D042 8613 D5BF A7CE 4BF5 sig A7CE4BF5 2000-08-06 datarecovery RSA-ADK pub 1024R/FD40B97D 2000-08-04 Eddie Clean (Testkey RSA) Key fingerprint = E2 09 C7 F2 25 0D A7 6D B4 35 1D 65 1C 1A 63 C5 sig FD40B97D 2000-08-04 Eddie Clean (Testkey RSA) key-F1 (with V4-self-signature): pub 1024R/80054131 2000-08-04 Freddie Clean (Testkey RSA) Key fingerprint = 2A54 7EE3 02C9 7B3E 504D 3DB6 4F74 526E 8005 4131 sig 80054131 2000-08-05 Freddie Clean (Testkey RSA) pub 1024D/206D91D7 2000-07-31 Test-CA (do not trust) Key fingerprint = 6981 DB23 9020 D3FC 1F3A FB51 7FE6 3208 206D 91D7 sig 206D91D7 2000-07-31 Test-CA (do not trust) sub 1024g/10505CFA 2000-07-31 sig 206D91D7 2000-07-31 Test-CA (do not trust)
________________________________________
________________________________________
Because of the fact that this chapter contains all the experimental data I have collected, it is full of details and should be read as the records of the experiments. I have tried to present the data as readable as possible leaving the interpretation of the experimental results to the next chapter.
I will present the experiments in chronological order. And you can find the fingerprints of all binary data produced during the experiments in this file.
PGP-2.6.3ia (PGP-Classic) UNIX |
|
PGP-5.0i UNIX |
|
PGP-5.5.3i WINDOWS |
|
PGP-6.5.1i WINDOWS |
|
GnuPG-1.0.1 UNIX |
|
________________________________________
But how can you be sure if you have got someone else's public key with a Version-4-self-signature?
________________________________________
________________________________________
The US-patent on RSA (No 4,405,829) expires in September
2000.
Cheers to the bottom, ..... !
________________________________________